import request from '@/app/utils/requestKey'
const baseURL = process.env.NEXT_PUBLIC_API_URL_ALIAS
const NODE_API = process.env.NEXT_PUBLIC_API_URL


// const ALBB_TOKEN = '/ALBB_TOKEN' 
// const PEOPLE = '/people'
const ALBB_TOKEN = process.env.NEXT_PUBLIC_TYPE == 'dev' ? '/ALBB_TOKEN' : process.env.NEXT_PUBLIC_API_URL_ALBB_TOKEN
const PEOPLE = process.env.NEXT_PUBLIC_TYPE == 'dev' ? '/people' : process.env.NEXT_PUBLIC_API_URL_PEOPLE

export const Human = (data: any, url = baseURL) => {
    return request.post('/human', data, {
        baseURL: url
    })
}

export const getJson = () => {
    return request.get('/get', {
        baseURL: NODE_API
    })
}

export const writeDocument = (file: string, content: any, type: string) => {
    return request.post('/Write_document', { file, content, type }, {
        baseURL: NODE_API
    })
}

export const people_stop = () => {
    return request.post('/stop', {}, {
        baseURL: PEOPLE
    })
}

export const people_start = (obj: any) => {
    return request.post('/start', obj, {
        baseURL: PEOPLE
    })
}

export const people_upload = (obj: any) => {
    return request.post('/upload', obj, {
        baseURL: PEOPLE,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

export const get_token = () => {
    return request.get('/get_token', {
        // baseURL: ALBB_TOKEN
        baseURL: 'http://localhost:6799'
    })
}

export const get_offer = (sdp: any, URL: any) => {
    return request.post('/offer', {
        type: "offer",
        sdp: sdp
    }, {
        baseURL: URL
    })
}


// const response = await fetch(
//     `${process.env.NEXT_PUBLIC_API_URL_ALIAS}/offer`,
//     {
//         method: "POST",
//         headers: { "Content-Type": "application/json" },
//         body: JSON.stringify({
//             type: "offer",
//             sdp: ''
//         }),
//     }
// );